package com.jkhan.demo.collection;

import java.util.Scanner;
import java.util.Vector;

public class TestScore {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Vector vector = new Vector();

        int maxScore = 0;

        for (; ; ) {
            System.out.println("请输入学生成绩（负数代表结束）");
            int score = scanner.nextInt();

            if (score < 0) {
                break;
            }

            if (score > 100) {
                System.out.println("输入数据不合法，请重新输入");
                continue;
            }

            Integer inScore = new Integer(score);
            vector.addElement(inScore);

            if (maxScore < score) {
                maxScore = score;
            }
        }

        char level;

        for (int i = 0; i < vector.size(); i++) {
            Object obj = vector.elementAt(i);
            Integer inScore = (Integer) obj;
            int score = inScore.intValue();
            int dValue = maxScore - score;

            if (dValue <= 10) {
                level = 'A';
            } else if (dValue <= 20) {
                level = 'B';
            } else if (dValue <= 30) {
                level = 'C';
            } else {
                level = 'D';
            }

            System.out.println("student-" + i + " score is " + score + ",level is " + level);

        }

    }

}